#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
开放商户 - 签约信息修改功能使用示例
"""

import os
import sys

# 添加项目根目录到Python路径，确保能够导入jlpay包
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from examples.base_example import BaseExample
from jlpay.services.openmerch.change.change_service import ChangeService
from jlpay.model.openmerch.change.sign_info_modify import SignInfoModifyRequest


class SignInfoModifyExample(BaseExample):
    """签约信息修改示例类"""
    
    def __init__(self):
        """初始化示例类"""
        super().__init__("examples.openmerch.change.sign_info_modify")
        self.change_service = ChangeService(self.config)
    
    def build_sign_info_modify_request(self):
        """构建签约信息修改请求"""
        request = SignInfoModifyRequest()
        
        # 设置请求参数 - 根据Java SignInfoModifyRequest.java中的字段定义
        request.set_org_no("50720711")  # 机构号
        request.set_merch_no("849584358140108")  # 商户号
        request.set_apply_id("b8659ea518d14c99b78b5ad000a0810D")  # 申请单号
        request.set_sign_mode("1")  # 签约方式
        request.set_agreement_pic("https://example.com/agreement.jpg")  # 纸质协议照片
        request.set_legal_person_phone("13800138000")  # 法人签约手机号码
        request.set_delegatee_phone("13800138001")  # 授权收款人签约手机号码
        
        return request
    
    def demo(self):
        """执行签约信息修改示例"""
        self.logger.info("开始执行签约信息修改示例")
        
        # 构建请求
        request = self.build_sign_info_modify_request()
        
        # 发送请求并处理响应
        self.send_request_and_handle_response(
            self.change_service.modify_sign_info,
            "签约信息修改",
            request
        )
        
        self.logger.info("签约信息修改示例执行完毕")


if __name__ == "__main__":
    example = SignInfoModifyExample()
    example.logger.info("=" * 50)
    example.logger.info("===== 签约信息修改示例 开始 =====")
    example.logger.info("=" * 50)
    
    example.demo()
    
    example.logger.info("=" * 50)
    example.logger.info("===== 签约信息修改示例执行完毕 =====")
    example.logger.info("=" * 50) 